<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
<meta http-equiv="Pragma" content="no-cache"> 
<meta http-equiv="Cache-Control" content="no-cache"> 
<meta http-equiv="Expires" content="0"> 
<title>登录页</title>
<link href="./css/login.css" rel="stylesheet" type="text/css">
    <script src="./vendor/jquery/jquery.min.js"></script>
</head>

<body style="zoom: 1;">
<div class="login_box">
      <div class="login_l_img"><img src="./imgs/nimages/login-img.png"></div>
      <div class="login">
          <div class="login_logo"><a href="javascript:void (0)"><img src="./imgs/nimages/login_logo.png"></a></div>
          <div class="login_name">
               <p>试卷管理系统</p>
          </div>
          <form method="post">
              <input id="login_name" name="username" type="text" placeholder="用户名" />
              <input id="login_code" name="password" type="password" placeholder="密码" />
              <input id="login_submit" value="登录" style="width:100%;" type="submit" />
          </form>
      </div>
      <!--div class="copyright">某某有限公司 版权所有©2016-2018 技术支持电话：000-00000000</div>-->
</div>


</body>
<script>
    $("#login_submit").on('click', function(){
        var name = $("#login_name").val();
        var code = $("#login_code").val();
        if(name == ""){
            $("#login_name").focus();
            alert("请输入账号");
        }else if(code == ""){
            $("#login_code").focus();
            alert("请输入密码");
        }else{
            $.ajax({
                url: "/sjgl/user/login",
                type: "POST",
                data: {
                    "login" : name,
                    "password" : code
                },
                dataType: "json",
                error: function () {
                    debugger;
                },
                success: function (data, status) { //如果调用php成功
                    if(data){
                        window.location = "index.html";
                    }else{
                        alert("账号密码错误");
                    }
                }
            });
        }

    });

    $(this).keydown(function (e){
        if(e.which == "13"){
            $("#login_submit").click();
        }
    });
</script>
</html>